# encoding: gbk
import os
import sys
import MySQLdb
import sys

reload(sys)
sys.setdefaultencoding('gbk')


def getStatus(conn):
    query = " SHOW SLAVE STATUS "

    # print query
    cursor = conn.cursor()
    cursor.execute(query)
    result = cursor.fetchall()
    return result[0]


def resolve(conn):
    cursor = conn.cursor()
    query1 = "set global sql_slave_skip_counter=1"
    query2 = "START SLAVE"
    query3 = "SHOW SLAVE STATUS"

    cursor.execute(query1)
    cursor.execute(query2)
    cursor.execute(query3)
    conn.commit()


if __name__ == '__main__':
    conn = MySQLdb.connect(host="192.168.2.102", user="mars", passwd="mars123", db="", port=3306, charset="utf8")
    status = getStatus(conn)

    if status[32] is None:
        """resolve(conn)"""
        print 'wq not resolved'
    """else:
        print 'wq resolved"""


